home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Eagles Nest BBS 8
/
Eagles_Nest_Mac_Collection_Disc_8.TOAST
/
Developer Tools⁄Additions
/
IntermediatC
/
Ships #6
/
teacher's control.c
< prev
next >
Wrap
C/C++ Source or Header
|
1990-10-25
|
1KB
|
51 lines
/*
CONTROL.C
Ships at Sea:
Create 25 ship locations (x,y) between -100 and 100 for each x and y. Determine
which 2 of the 25 ships are closest together. Print the locations of all ships
and the numbers of the 2 closest ships. Three modules must be used:
control.c contains main()
compute.c creates the ship locations and locates the 2 closest ships
output.c prints data to disk
*/
/*
This is control.c. This module will call upon other modules
to create a list of 25 ships, to locate the nearest pair, and
to output their locations and the nearest hull numbers.
*/
/* No includes needed in this module */
#define SHIPS_AT_SEA 25
/* Declarations of functions defined in other modules. */
extern void create_locations
(double latitudes[], double longitudes[], int no_of_ships);
extern void locate_nearest_pair
(int nearest_subscripts[], double latitudes[], double longitudes[],
int no_of_ships);
extern void produce_output
(int nearest_subscripts[], double latitudes[], double longitudes[],
int no_of_ships);
main()
{
double latitudes[SHIPS_AT_SEA], longitudes[SHIPS_AT_SEA];
int nearest_subscripts[2];
create_locations(latitudes, longitudes, SHIPS_AT_SEA);
locate_nearest_pair(nearest_subscripts, latitudes, longitudes, SHIPS_AT_SEA);
produce_output(nearest_subscripts, latitudes, longitudes, SHIPS_AT_SEA);
}